home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
5
/
CHASSIS_
/
SHOWINFO.C
< prev
next >
Wrap
Text File
|
1992-05-14
|
3KB
|
77 lines
/************************************************************************************/
/* ShowInfoDlog */
/* This proc dislpays a dialog with only simple text and an OK button (item #1), */
/* an optional Cancel button (item #2), and a userItem surrounding the OK button */
/* (item #3), an optional icon (item #4) and optional version info (item #5). */
/* */
/* Note. Item number of userItems are hardcoded. */
/************************************************************************************/
#include "MyHeaders.h"
int ShowInfoDlog(int dlogNo)
{
int SIRetCode = 0;
Rect dlogRect;
int rectHeight, rectWidth;
int newH, newV;
int itemHit; /* return from modal dialog */
myDlogPtr = GetNewDialog (dlogNo, NIL, (WindowPtr) -1); /* get the dialog */
dlogRect = (*myDlogPtr).portRect; /* position dlog on desktop */
rectHeight = dlogRect.bottom - dlogRect.top;
rectWidth = dlogRect.right - dlogRect.left;
newH = (screenBits.bounds.right - rectWidth) * .50; /* centered horizonally */
if (newH < 10) /* (not less than 10) */
newH = 10;
newV = ((screenBits.bounds.bottom - 30 /* vertical position */
- rectHeight)* (.33)) + 30; /* one-third down */
if (newV < 30) /* (not less than 30) */
newV = 30;
MoveWindow (myDlogPtr, newH, newV, TRUE); /* move to new position */
GetDItem (myDlogPtr, 3, &workInt, /* get info about useritem */
&workHandle, &workRect); /* (must be item #3) */
SetDItem (myDlogPtr, 3, userItem, /* insert draw proc pointer */
(Handle) DrawDefaultBorder, &workRect); /* into info about useritem */
/* if there is an icon, it */
/* will be a disabled user */
/* item whose item # is 4 */
GetDItem (myDlogPtr, 4, &workInt, /* get info about useritem */
&workHandle, &workRect); /* (must be item #4) */
if (workInt == userItem + itemDisable) /* if a disabled useritem */
SetDItem (myDlogPtr, 4, userItem, /* put icon draw proc ptr */
(Handle) DrawUserIcon, &workRect); /* into info about useritem */
SetPort (myDlogPtr);
TextFont(geneva);
TextFace(NIL);
TextSize(10);
ParamText (versLongStr,"","",""); /* Set substitution string */
CursorSelect (NIL, NIL, NIL); /* get arrow csr for dialog */
ShowWindow (myDlogPtr); /* make visible */
itemHit = 0; /* initialize before loop */
while ((itemHit != ok) && (itemHit != cancel)) /* loop till ok or cancel */
ModalDialog(NIL, &itemHit); /* stick here until a hit */
if (dlogNo == 130) /* if it is the Kudos dlog */
{ /* perform applause */
theSnd = GetResource ('snd ', 9001); /* before disposing of */
theSndChan = NIL; /* the dialog. */
sndRC = SndPlay (theSndChan, theSnd, TRUE);
ReleaseResource (theSnd);
}
DisposDialog(myDlogPtr); /* release storage, etc. */
SIRetCode = itemHit; /* return: 1=ok, 2=cancel */
return SIRetCode;
}